﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESF.General.Entity;
using System.Drawing.Printing;
using MessagingToolkit.Barcode;

#endregion


namespace ESF.WinForms.Controls.Barcodes
{
	public class StickerPageSettings : ESF.General.Entity.BasicReference
	{
		#region Constantes
		
		public float MMTOIN_FACTOR = (float) 0.0393700787;

		#endregion


		#region Miembros

		public int StickerWidth_mm;

		public int StickerHeight_mm;

		public int StickerVerticalSeparator_mm;

		public int StickerHorizontalSeparator_mm;

		public int StickerRowCount;

		public int StickerPageCount;

		public int PageMarginTop_mm;
		public int PageMarginRight_mm;
		public int PageMarginBottom_mm;
		public int PageMarginLeft_mm;

		public bool StickerIncludeBorders;

		public int BarcodeWidth;

		public int BarcodeHeight;

		public int BarcodeModuleSize;

		public BarcodeFormat BarcodeFormat;

		public bool ShowBarcodeSeparated;

		public bool ShowBarcode;

		#endregion


		#region Propiedades

		public PaperSize PaperSize
		{
			get
			{
				int rows;


				rows = (int) Math.Floor (StickerPageCount / (1.0 * StickerRowCount));

				return new PaperSize ()
				{
					PaperName = "Custom",
					Height = (int) Math.Ceiling ((PageMarginTop_in100 + PageMarginBottom_in100) + (StickerHeight_in100 * rows) + 
					    (StickerHorizontalSeparator_in100 * (rows - 1))),
					Width = (int) Math.Ceiling ((PageMarginLeft_in100 + PageMarginRight_in100) + (StickerWidth_in100 * StickerRowCount) + 
					    (StickerVerticalSeparator_in100 * (StickerRowCount - 1)))
				};
			}
		}

		#endregion


		#region Inches
		
		public float StickerWidth_in
		{
			get
			{
				return StickerWidth_mm * MMTOIN_FACTOR;
			}
		}

		public float StickerHeight_in
		{
			get
			{
				return StickerHeight_mm * MMTOIN_FACTOR;
			}
		}

		public float StickerVerticalSeparator_in
		{
			get
			{
				return StickerVerticalSeparator_mm * MMTOIN_FACTOR;
			}
		}

		public float StickerHorizontalSeparator_in
		{
			get
			{
				return StickerHorizontalSeparator_mm * MMTOIN_FACTOR;
			}
		}

		public float PageMarginTop_in
		{
			get
			{
				return PageMarginTop_mm * MMTOIN_FACTOR;
			}
		}

		public float PageMarginRight_in
		{
			get
			{
				return PageMarginRight_mm * MMTOIN_FACTOR;
			}
		}

		public float PageMarginBottom_in
		{
			get
			{
				return PageMarginBottom_mm * MMTOIN_FACTOR;
			}
		}

		public float PageMarginLeft_in
		{
			get
			{
				return PageMarginLeft_mm * MMTOIN_FACTOR;
			}
		}

		#endregion


		#region Hundred of Inches
		
		public float StickerWidth_in100
		{
			get
			{
				return StickerWidth_in * 100;
			}
		}

		public float StickerHeight_in100
		{
			get
			{
				return StickerHeight_in * 100;
			}
		}

		public float StickerVerticalSeparator_in100
		{
			get
			{
				return StickerVerticalSeparator_in * 100;
			}
		}

		public float StickerHorizontalSeparator_in100
		{
			get
			{
				return StickerHorizontalSeparator_in * 100;
			}
		}

		public float PageMarginTop_in100
		{
			get
			{
				return PageMarginTop_in * 100;
			}
		}

		public float PageMarginRight_in100
		{
			get
			{
				return PageMarginRight_in * 100;
			}
		}

		public float PageMarginBottom_in100
		{
			get
			{
				return PageMarginBottom_in * 100;
			}
		}

		public float PageMarginLeft_in100
		{
			get
			{
				return PageMarginLeft_in * 100;
			}
		}

		#endregion


		#region ToString 

		public override string ToString()
		{
			return string.Format ("Sticker (mm): {0}x{1}, Separadores (mm): {2}x{3}, Item x Página: {4}x{5}",
				StickerWidth_mm, StickerHeight_mm, 
				StickerVerticalSeparator_mm, StickerHorizontalSeparator_mm, 
				StickerRowCount, StickerPageCount);
		}

		#endregion
	}
}
